package com.lazycat.backend.service.impl.cart;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lazycat.backend.mapper.ShoppingCarMapper;
import com.lazycat.backend.pojo.UserShoppingCar;
import com.lazycat.backend.service.cart.ClearCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class ClearCartServiceImpl implements ClearCartService {

    @Autowired
    private ShoppingCarMapper shoppingCarMapper;


    @Override
    public Map<String, Object> clear(Integer userId) {
        QueryWrapper<UserShoppingCar> userShoppingCarQueryWrapper = new QueryWrapper<>();
        userShoppingCarQueryWrapper.eq("user_id", userId);
        shoppingCarMapper.delete(userShoppingCarQueryWrapper);
        HashMap<String, Object> resp = new HashMap<>();
        resp.put("error_message", "success");
        return resp;
    }
}
